package name.matthewgreet.strutscommons.util; import java.io.Serializable; import name.matthewgreet.strutscommons.util.ListCache.ListCacheConfig; /** * <P>Template for web level, session-based caching a master, record list with four slave lists for editing in various * web pages. Subclasses of this, as well as defining the record types, typically set list finders and other * Strategies for record list relationships and pagination that clients don't set themselves, depending on web page * workflow. Instances are typically created as Singletons.</P> * * <TABLE CLASS="main"> * <CAPTION>Generic types</CAPTION> * <TR CLASS="row_odd"> * <TD>KM</TD><TD>Type of primary key of master records</TD> * </TR> * <TR CLASS="row_even"> * <TD>TM</TD><TD>Type of master records</TD> * </TR> * <TR CLASS="row_odd"> * <TD>K1</TD><TD>Type of primary key of slave list 1 records</TD> * </TR> * <TR CLASS="row_even"> * <TD>T1</TD><TD>Type of slave list 1 records</TD> * </TR> * <TR CLASS="row_odd"> * <TD>K2</TD><TD>Type of primary key of slave list 2 records</TD> * </TR> * <TR CLASS="row_even"> * <TD>T2</TD><TD>Type of slave list 2 records</TD> * </TR> * <TR CLASS="row_even"> * <TD COLSPAN="2">etc.</TD> * </TR> * </TABLE> * * <P>As there are a bewildering set of configuration options and client Struts actions are expected to know their * responsibilities in workflow, subclasses are a convenient Javadoc reference point for documenting this, such as * below.</P> * * <TABLE CLASS="main"> * <CAPTION>Example Javadoc</CAPTION> * <TR> * <TH>Slave list no</TH> * <TH>Name</TH> * <TH>Description</TH> * <TH>Viewer action</TH> * <TH>Base record</TH> * <TH>Other base record data</TH> * <TH>Page extension data</TH> * <TH>Detail data</TH> * <TH>Pagination mode</TH> * <TH>List/id/size finder</TH> * <TH>Page finder/ page extension assembler</TH> * <TH>Single item finder</TH> * </TR> * <TR CLASS="row_odd"> * <TD>Master</TD> * <TD>Board games</TD> * <TD>Board games in Board Game Geek database up to 2022</TD> * <TD><CODE>ViewGameListAction</CODE></TD> * <TD><CODE>GameDTO</CODE></TD> * <TD> </TD> * <TD>Related designers</TD> * <TD>Related artists, mechanics, and publishers</TD> * <TD STYLE="text-align: center">Depends on search criteria</TD> * <TD STYLE="text-align: center">Supplied by FindGameListByDesignerNameAction, FindGameListByFamileAction, FindGameListByNameContainsAction and FindGameListByRankAction</TD> * <TD STYLE="text-align: center">GamePageByIdsFinder, GamePageExtensionAssembler</TD> * <TD STYLE="text-align: center">GameItemFinder</TD> * </TR> * <TR CLASS="row_even"> * <TD>1</TD> * <TD>Ratings distribution</TD> * <TD>Counts of each user ratings of 0 to 10</TD> * <TD><CODE>ViewRatingDistributionListAction</CODE></TD> * <TD><CODE>GameRatingDTO</CODE></TD> * <TD> </TD> * <TD> </TD> * <TD> </TD> * <TD STYLE="text-align: center">Full list</TD> * <TD STYLE="text-align: center">GameRatingByGameIdListFinder</TD> * <TD STYLE="text-align: center">N/A</TD> * <TD STYLE="text-align: center"> </TD> * </TR> * <TR CLASS="row_odd"> * <TD>2</TD> * <TD>User ratings</TD> * <TD>Individual user ratings</TD> * <TD><CODE>ViewUserRatingListAction</CODE></TD> * <TD>UserRatingDTO</TD> * <TD> </TD> * <TD>Owning username</TD> * <TD> </TD> * <TD STYLE="text-align: center">Base record list</TD> * <TD STYLE="text-align: center">Supplied by FindUserRatingListByUsernameContainsAction and FindUserRatingListByRatingAction</TD> * <TD STYLE="text-align: center">UserRatingPageExtensionAssembler</TD> * <TD STYLE="text-align: center"> </TD> * </TR> * </TABLE> * <P> </P> * <PRE CLASS="code"> * <TABLE CLASS="main"> * <CAPTION>Board games</CAPTION> * <TR> * <TH>Slave list no</TH> * <TH>Name</TH> * <TH>Description</TH> * <TH>Viewer action</TH> * <TH>Base record</TH> * <TH>Other base record data</TH> * <TH>Page extension data</TH> * <TH>Detail data</TH> * <TH>Pagination mode</TH> * <TH>List/id/size finder</TH> * <TH>Page finder/ page extension assembler</TH> * <TH>Single item finder</TH> * </TR> * <TR CLASS="row_odd"> * <TD>Master</TD> * <TD>Board games</TD> * <TD>Board games in Board Game Geek database up to 2022</TD> * <TD><CODE>ViewGameListAction</CODE></TD> * <TD><CODE>GameDTO</CODE></TD> * <TD>&nbsp;</TD> * <TD>Related designers</TD> * <TD>Related artists, mechanics, and publishers</TD> * <TD STYLE="text-align: center;">Depends on search criteria</TD> * <TD STYLE="text-align: center;">Supplied by FindGameListByDesignerNameAction, FindGameListByFamileAction, FindGameListByNameContainsAction and FindGameListByRankAction</TD> * <TD STYLE="text-align: center;">GamePageByIdsFinder, GamePageExtensionAssembler</TD> * <TD STYLE="text-align: center;">GameItemFinder</TD> * </TR> * <TR CLASS="row_even"> * <TD>1</TD> * <TD>Ratings distribution</TD> * <TD>Counts of each user ratings of 0 to 10</TD> * <TD><CODE>ViewRatingDistributionListAction</CODE></TD> * <TD><CODE>GameRatingDTO</CODE></TD> * <TD>&nbsp;</TD> * <TD>&nbsp;</TD> * <TD>&nbsp;</TD> * <TD STYLE="text-align: center;">Full list</TD> * <TD STYLE="text-align: center;">GameRatingByGameIdListFinder</TD> * <TD STYLE="text-align: center;">N/A</TD> * <TD STYLE="text-align: center;">&nbsp;</TD> * </TR> * <TR CLASS="row_odd"> * <TD>2</TD> * <TD>User ratings</TD> * <TD>Individual user ratings</TD> * <TD><CODE>ViewUserRatingListAction</CODE></TD> * <TD>UserRatingDTO</TD> * <TD>&nbsp;</TD> * <TD>Owning username</TD> * <TD>&nbsp;</TD> * <TD STYLE="text-align: center;">Base record list</TD> * <TD STYLE="text-align: center;">Supplied by FindUserRatingListByUsernameContainsAction and FindUserRatingListByRatingAction</TD> * <TD STYLE="text-align: center;">UserRatingPageExtensionAssembler</TD> * <TD STYLE="text-align: center;">&nbsp;</TD> * </TR> * </TABLE> * </PRE> */ public abstract class AbstractCompositeCache_4S<KM extends Serializable,TM extends Serializable, K1 extends Serializable,T1 extends Serializable, K2 extends Serializable,T2 extends Serializable, K3 extends Serializable,T3 extends Serializable, K4 extends Serializable,T4 extends Serializable> extends AbstractCompositeCache_3S<KM,TM,K1,T1,K2,T2,K3,T3> { private static final long serialVersionUID = -1843533976240270745L; private ListCache<TM,K4,T4> slaveList4; protected AbstractCompositeCache_4S() { super(); ListCacheConfig<TM,K4,T4> slaveListCacheConfig = getSlaveListCache4Config(); slaveList4 = new ListCache<TM,K4,T4>(slaveListCacheConfig, getMasterListCache()); slaveList4.addListCacheListener(listCache -> {notifySlaveListCache4Changed(listCache);}); } public AbstractCompositeCache_4S(AbstractCompositeCache_4S<KM,TM,K1,T1,K2,T2,K3,T3,K4,T4> abstractCompositeCache) throws Exception { super(abstractCompositeCache); slaveList4 = new ListCache<TM,K4,T4>(abstractCompositeCache.getSlaveListCache4(), getMasterListCache()); slaveList4.addListCacheListener(listCache -> {notifySlaveListCache4Changed(listCache);}); } /** * Overridden by concrete implementations to configure slave list cache 4. */ protected abstract ListCacheConfig<TM,K4,T4> getSlaveListCache4Config(); /** * Notification that the slave list cache 4 has changed. */ protected void notifySlaveListCache4Changed(ListCache<?,?,T4> listCache) { // Nothing but may be overridden. } /** * Returns cache of slave list 4. */ public ListCache<TM,K4,T4> getSlaveListCache4() { return slaveList4; } }